home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / octa209s.zip / octave-2.09 / src / oct-strstrm.cc < prev    next >
C/C++ Source or Header  |  1997-01-29  |  2KB  |  82 lines

  1. /*
  2.  
  3. Copyright (C) 1996 John W. Eaton
  4.  
  5. This file is part of Octave.
  6.  
  7. Octave is free software; you can redistribute it and/or modify it
  8. under the terms of the GNU General Public License as published by the
  9. Free Software Foundation; either version 2, or (at your option) any
  10. later version.
  11.  
  12. Octave is distributed in the hope that it will be useful, but WITHOUT
  13. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14. FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  15. for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with Octave; see the file COPYING.  If not, write to the Free
  19. Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  20.  
  21. */
  22.  
  23. #ifdef HAVE_CONFIG_H
  24. #include <config.h>
  25. #endif
  26.  
  27. #include "oct-strstrm.h"
  28.  
  29. // Position a stream at OFFSET relative to ORIGIN.
  30.  
  31. int
  32. octave_base_strstream::seek (streamoff offset, ios::seek_dir origin)
  33. {
  34.   int retval = -1;
  35.  
  36.   if (! bad ())
  37.     {
  38.       streambuf *sb = rdbuf ();
  39.  
  40.       if (sb)
  41.     {
  42.       clear ();
  43.  
  44.       sb->seekoff (offset, origin);
  45.       retval = bad () ? -1 : 0;
  46.     }
  47.     }
  48.  
  49.   return retval;
  50. }
  51.  
  52. // Return current stream position.
  53.  
  54. long
  55. octave_base_strstream::tell (void) const
  56. {
  57.   long retval = -1;
  58.  
  59.   if (! bad ())
  60.     {
  61.       // XXX FIXME XXX -- shouldn't have to do this!
  62.  
  63.       streambuf *sb = ((octave_base_strstream *)this)->rdbuf ();
  64.  
  65.       if (sb)
  66.     {
  67.       retval = (long) sb->seekoff (0, ios::cur);
  68.  
  69.       if (bad ())
  70.         retval = -1;
  71.     }
  72.     }
  73.  
  74.   return retval;
  75. }
  76.  
  77. /*
  78. ;;; Local Variables: ***
  79. ;;; mode: C++ ***
  80. ;;; End: ***
  81. */
  82.